﻿using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace StockLib
{
    /// <summary>
    /// 股票信息
    /// </summary>
    public class StockBlock : Dictionary<string, Stock>
    {
        public string Name { get; set; }
        public string ShortName { get; set; }
        public string GroupName { get; set; }
        public int StockNumber { get; set; }
        public object Reserved1 { get; set; }
        public object Reserved2 { get; set; }
        public object Reserved3 { get; set; }

        public string BlockId
        {
            get
            {
                return GroupId + Name;
            }
            set
            {
                string pattern = @"^(\w+)\.(\w+)$";
                Match match = Regex.Match(value, pattern);
                if (!match.Success)
                    return;

                Name = match.Groups[2].Value;
                GroupName = match.Groups[1].Value;
            }
        }

        public string GroupId
        {
            get
            {
                return GroupName + ".";
            }
        }

        public StockBlock()
            : base()
        {
        }
    }
}
